// 客户端
import {request} from './request.js'

// 根据id和tag显示文章列表
function getTopics(page, tag,category_id) {
  return request({
    url: '/thread/list',
    data: {
      page,
      tag,
      category_id
    },
    method:'post'
  })
}
function getMyTopics(page, tag) {
  return request({
    url: '/user/thread',
    data: {
      page,
      tag,
    },
    method:'post'
  })
}


// 根据id获取文章
function getTopic(thread_id) {
  return request({
    url: '/thread/detail',
    params: {
      thread_id
    }
  })
}
function getComment(thread_id) {
  return request({
    url: '/comment/list',
    method:'post',

    data: {
      thread_id
    }
  })
}


function searchTopics(str, page=1) {
  return request({
    url: '/search',
    method:'post',
    data: {
      search: str,
      page: page
    }
  })
}

function getBanner() {
  return request({
    url: '/banner'
  })
}

function getCategory() {
  return request({
    url: '/category',
    data: {

    },
    method:'post'
  })
}

function getLinks(limit) {
  return request({
    url: '/link/list',
    params:{
      limit
    }
  })
}
function getTotals() {
  return request({
    url: '/totals',
  })
}
function getScore(limit) {
  return request({
    url: '/score',
    params:{
      limit
    }
  })
}
export default {getTopics, getTopic,getCategory, searchTopics,getMyTopics, getBanner,getLinks,getComment,getTotals,getScore}
